import java.util.Stack;

public class MyQueue {

    private Stack<Integer> stackX;
    private Stack<Integer> stackY;
    private int front;

    public MyQueue() {
        stackX = new Stack<>();
        stackY = new Stack<>();
    }

    public void push(int x) {
        if(stackX.isEmpty()){
            front = x;
        }
        while(!stackX.isEmpty()){
            stackY.push(stackX.pop());
        }
        stackX.push(x);
        while(!stackY.isEmpty()){
            stackX.push(stackY.pop());
        }
    }

    public int pop() {
        int tem = stackX.pop();
        if(!stackX.isEmpty()){
            front = stackX.peek();
        }
        return tem;
    }

    public int peek() {
        return front;

    }

    public boolean empty() {
        return stackX.isEmpty()&&stackY.isEmpty();
    }
}

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */